<%@page import="com.kucun.bean.Users"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
Users user= (Users)request.getSession().getAttribute("user");
response.flushBuffer();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>欢迎使用资产管理系统</title>
<link id="swicth-style" rel="stylesheet" type="text/css" href="../easyui-1.3/themes/pepper-grinder/easyui.css"  >
<script type="text/javascript" src="../easyui-1.3/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../easyui-1.3/jquery.easyui.min.js"></script>
<style type="text/css">
body {
	font: 12px/20px "微软雅黑", "宋体", Arial, sans-serif, Verdana, Tahoma;
	padding: 0;
	margin: 0;
}
a:link {
 text-decoration: none;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: underline;
}
a:active {
 text-decoration: none;
}
.cs-north {
	height:79px;
}
.cs-north-bg {
	width: 100%;
	height: 100%;
	//background: url(../easyui-1.3/themes/gray/images/header_bg.png) repeat-x;
}
.cs-north-logo {
	height: 40px;
	width: 70%;
	margin: 15px 0px 0px 5px;
	display: inline-block;
	color:#000000;font-size:15px;font-weight:bold;text-decoration:none
}
.cs-west {
	width:200px;padding:0px;
}
.cs-south {
	height:25px;background:url('../easyui-1.3/themes/pepper-grinder/images/ui-bg_fine-grain_15_ffffff_60x60.png') repeat-x;padding:0px;text-align:center;
}
.cs-navi-tab {
	padding: 5px;
}
.cs-tab-menu {
	width:120px;
}
.cs-home-remark {
	padding: 10px;
}
.wrapper {
    float: right;
    height: 30px;
    margin-left: 10px;
}
.ui-skin-nav {
    float: right;
	padding: 0;
	margin-right: 10px;
	list-style: none outside none;
	height: 30px;
}

.ui-skin-nav .li-skinitem {
    float: left;
    font-size: 12px;
    line-height: 30px;
	margin-left: 10px;
    text-align: center;
}
.ui-skin-nav .li-skinitem span {
	cursor: pointer;
	width:10px;
	height:10px;
	display:inline-block;
}
.ui-skin-nav .li-skinitem span.cs-skin-on{
	border: 1px solid #FFFFFF;
}

.ui-skin-nav .li-skinitem span.gray{background-color:gray;}
.ui-skin-nav .li-skinitem span.pepper-grinder{background-color:#BC3604;}
.ui-skin-nav .li-skinitem span.blue{background-color:blue;}
.ui-skin-nav .li-skinitem span.cupertino{background-color:#D7EBF9;}
.ui-skin-nav .li-skinitem span.dark-hive{background-color:black;}
.ui-skin-nav .li-skinitem span.sunny{background-color:#FFE57E;}
</style>
<script type="text/javascript">
  var role="<%=user.getPower()%>";  
  var userid="<%=user.getUserid() %>";
  var ma="<%=user.getPassword() %>";
  var path="<%=basePath%>"; 
  
function addTab(title, url){
	if ($('#tabs').tabs('exists', title)){
		$('#tabs').tabs('select', title);//选中并刷新
		var currTab = $('#tabs').tabs('getSelected');
		var url = $(currTab.panel('options').content).attr('src');
		if(url != undefined && currTab.panel('options').title != 'Home') {
			$('#tabs').tabs('update',{
				tab:currTab,
				options:{
					content:createFrame(url)
				}
			})
		}
	} else {
		var content = createFrame(url);
		$('#tabs').tabs('add',{
			title:title,
			content:content,
			closable:true
		});
	}
	tabClose();
}
function createFrame(url) {
	var s = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
	return s;
}
		
function tabClose() {
	/*双击关闭TAB选项卡*/
	$(".tabs-inner").dblclick(function(){
		var subtitle = $(this).children(".tabs-closable").text();
		$('#tabs').tabs('close',subtitle);
	})
	/*为选项卡绑定右键*/
	$(".tabs-inner").bind('contextmenu',function(e){
		$('#mm').menu('show', {
			left: e.pageX,
			top: e.pageY
		});

		var subtitle =$(this).children(".tabs-closable").text();

		$('#mm').data("currtab",subtitle);
		$('#tabs').tabs('select',subtitle);
		return false;
	});
}		
//绑定右键菜单事件
function tabCloseEven() {
	//刷新
	$('#mm-tabupdate').click(function(){
		var currTab = $('#tabs').tabs('getSelected');
		var url = $(currTab.panel('options').content).attr('src');
		if(url != undefined && currTab.panel('options').title != 'Home') {
			$('#tabs').tabs('update',{
				tab:currTab,
				options:{
					content:createFrame(url)
				}
			})
		}
	})
	//关闭当前
	$('#mm-tabclose').click(function(){
		var currtab_title = $('#mm').data("currtab");
		$('#tabs').tabs('close',currtab_title);
	})
	//全部关闭
	$('#mm-tabcloseall').click(function(){
		$('.tabs-inner span').each(function(i,n){
			var t = $(n).text();
			if(t != 'Home') {
				$('#tabs').tabs('close',t);
			}
		});
	});
	//关闭除当前之外的TAB
	$('#mm-tabcloseother').click(function(){
		var prevall = $('.tabs-selected').prevAll();
		var nextall = $('.tabs-selected').nextAll();		
		if(prevall.length>0){
			prevall.each(function(i,n){
				var t=$('a:eq(0) span',$(n)).text();
				if(t != 'Home') {
					$('#tabs').tabs('close',t);
				}
			});
		}
		if(nextall.length>0) {
			nextall.each(function(i,n){
				var t=$('a:eq(0) span',$(n)).text();
				if(t != 'Home') {
					$('#tabs').tabs('close',t);
				}
			});
		}
		return false;
	});
	//关闭当前右侧的TAB
	$('#mm-tabcloseright').click(function(){
		var nextall = $('.tabs-selected').nextAll();
		if(nextall.length==0){
			//msgShow('系统提示','后边没有啦~~','error');
			alert('后边没有啦~~');
			return false;
		}
		nextall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			$('#tabs').tabs('close',t);
		});
		return false;
	});
	//关闭当前左侧的TAB
	$('#mm-tabcloseleft').click(function(){
		var prevall = $('.tabs-selected').prevAll();
		if(prevall.length==0){
			alert('到头了，前边没有啦~~');
			return false;
		}
		prevall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			$('#tabs').tabs('close',t);
		});
		return false;
	});

	//退出
	$("#mm-exit").click(function(){
		$('#mm').menu('hide');
	})
}

$(function() {
	tabCloseEven();

	$('.cs-navi-tab').click(function() {
		var $this = $(this);
		var href = $this.attr('src');
		var title = $this.text();
		addTab(title, href);
	});

	var themes = {
		'gray' : '../easyui-1.3/themes/gray/easyui.css',
		'pepper-grinder' : '../easyui-1.3/themes/pepper-grinder/easyui.css',
		'blue' : '../easyui-1.3/themes/default/easyui.css',
		'cupertino' : '../easyui-1.3/themes/cupertino/easyui.css',
		'dark-hive' : '../easyui-1.3/themes/dark-hive/easyui.css',
		'sunny' : '../easyui-1.3/themes/sunny/easyui.css'
	};

	var skins = $('.li-skinitem span').click(function() {
		var $this = $(this);
		if($this.hasClass('cs-skin-on')) return;
		skins.removeClass('cs-skin-on');
		$this.addClass('cs-skin-on');
		var skin = $this.attr('rel');
		$('#swicth-style').attr('href', themes[skin]);
		setCookie('cs-skin', skin);
		skin == 'dark-hive' ? $('.cs-north-logo').css('color', '#FFFFFF') : $('.cs-north-logo').css('color', '#000000');
	});

	if(getCookie('cs-skin')) {
		var skin = getCookie('cs-skin');
		$('#swicth-style').attr('href', themes[skin]);
		$this = $('.li-skinitem span[rel='+skin+']');
		$this.addClass('cs-skin-on');
		skin == 'dark-hive' ? $('.cs-north-logo').css('color', '#FFFFFF') : $('.cs-north-logo').css('color', '#000000');
	}
});


function setCookie(name,value) {//两个参数，一个是cookie的名子，一个是值
    var Days = 30; //此 cookie 将被保存 30 天
    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(name) {//取cookies函数        
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;
}


/*******修改当前密码********/
function savepassword(){
	//userid
	var s=$("#passwordid").form('validate');
	if(s){
	var jmm=$("#jmm").val();
	var xmm=$("#xmm").val();
	var qrmm=$("#qrmm").val();
	//alert(jmm  +"="+xmm+"     ---"+qrmm);
	if(jmm==''){
		alert("请输入旧密码！");
		return false;
	}else if(jmm!=ma){
		alert("输入旧密码错误，请重新输入！");
		return false;
	}else if(xmm==''){
		alert("请输入新密码！");
		return false;
	}else if(qrmm!=xmm){
		alert("请输入新密码与确认密码不一致！请重新输入！");
		return false;
	}else{
		$.messager.confirm('确认对话框', '您真的想要修改密码？', function(r){
		    if (r){
			var param="userid="+userid+"&qrmm="+qrmm;
/*			  param = encodeURI(param);
			  param = encodeURI(param);	*/
			$.ajax({  
			      type:'post',      
			      url:path+'users/updateuserpassword.html?new='+Math.random(),  
			      data:param, 
			      cache:false,
			    //  dataType:'json', 
			      success:function(data){
			    	  if(data=='ok'){
			    		  alert("密码更新成功！请退出后重新登录系统！");
			    		  $('#passwordid').window('close');
			    		  window.location.href=path+"/login.jsp"; 
			    		  return false;
			    	  }else{
			    		  alert("抱歉！密码更新失败！");
			    		  $('#passwordid').window('close');
			    		  return false;
			    	  }
			      },
			      error: function(jqXHR, textStatus, errorThrown) {
			    	  switch (jqXHR.status){  
			          case(500):  
			              alert("服务器系统内部错误");  
			              break;  
			          case(401):  
			              alert("未登录");  
			              break;  
			          case(403):  
			              alert("无权限执行此操作");  
			              break;  
			          case(408):  
			              alert("请求超时");  
			              break;  
			          default:  
			              alert("未知错误");  
			      }  
			      }
			  }); 
				}
			});
	}
	}
}
//退出
function clears(s){
	   var xmlHttpRequest=creatXMLHttpRequest();
 	   if(xmlHttpRequest){
 	    //第二步，需要知道是服务器的那个路径？
 		var surl =s+"users/exit.html";
 		//第三步，要开始发送请求,要想把请求发送到服务器，我们就需要使用 open() 方法和 send() 方法。
 		xmlHttpRequest.open("post",surl,true);
 		xmlHttpRequest.send(null);
 		//第四步。根据readyState状态值的改变然后去确定数据是否回传回来
 		xmlHttpRequest.onreadystatechange=function(){
 			if(xmlHttpRequest.readyState==4){
 				//保证浏览器接收数据正常
 				if(xmlHttpRequest.status==200){
 					location.href="../login.jsp"; 
 				}
 		    }     
 	       };
 		
 	   }
} 

function creatXMLHttpRequest(){
    var xmlHttp="";
    try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
 catch (e)
 {
 // Internet Explorer
 try
   {
   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
   }
 catch (e)
   {
   try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
   catch (e)
      {
      alert("您的浏览器不支持AJAX！");
      return false;
      }
   }
 }
return xmlHttp;
}


function getDateDemo(){   
             //分别获取年、月、日、时、分、秒  
             var myDate = new Date();  
             var year = myDate.getFullYear();  
             var month = myDate.getMonth() + 1;  
             var date = myDate.getDate();  
             var hours = myDate.getHours();  
             var minutes = myDate.getMinutes();  
             var seconds = myDate.getSeconds();  
               
             //月份的显示为两位数字如09月  
             if(month < 10 ){  
                 month = "0" + month;  
             }  
             if(date < 10 ){  
                 date = "0" + date;  
             }  
               
             //时间拼接  
             var dateTime = year + "年" + month + "月" + date + "日" + hours + "时" + minutes + "分" + seconds + "秒";  
               
             //document.write(dateTime);//打印当前时间  
             $("#dd").remove();
             $("#time").append("<span id='dd'>"+dateTime+"</span>");
     }     
     window.setInterval("getDateDemo()",1000);//每隔1秒，调用一次getDateDemo()  
</script>
</head>
<body class="easyui-layout">
	<div region="north" border="true" class="cs-north">
		<div class="cs-north-bg">
		<div class="cs-north-logo">
			              <table width="100%"  border=0  style="margin: -10px 0px 0px 5px;">
			                 <tr>
			                         <td width="20%"><img alt="" src="<%=basePath%>img/bglogo.png"> </td>
			                      <!--    <td width="10%"  style="font-size: 12px;font-weight: bold;">佛山机房</td> -->
			                         <td  nowrap style="white-space:nowrap;word-break:nowrap;font-size: 12px;" align="right"  width="30%">
			                         <a href="javascript:void(0);" class="easyui-menubutton" data-options="iconCls:'icon-man'" id="test123456" menu="#layout_north_zxMenu" style="color:black;" >${user.logname} </a> 
			                         【${user.username}】
			                         【<c:if test="${user.power==1}"> GUEST </c:if>
								     <c:if test="${user.power==10}">
								             操作员
								     </c:if>
								     <c:if test="${user.power==100}">
								             超级管理员
								     </c:if>】
								                    
			                          </td>
			                          <td width="20%"><div id="time"  style="font-size: 12px;">当前时间:&nbsp;</div></td>
                       </tr>
			           </table>
        </div>
		<ul class="ui-skin-nav">				
			<li class="li-skinitem" title="gray"><span class="gray" rel="gray"></span></li>
			<li class="li-skinitem" title="pepper-grinder"><span class="pepper-grinder" rel="pepper-grinder"></span></li>
			<li class="li-skinitem" title="blue"><span class="blue" rel="blue"></span></li>
			<li class="li-skinitem" title="cupertino"><span class="cupertino" rel="cupertino"></span></li>
			<li class="li-skinitem" title="dark-hive"><span class="dark-hive" rel="dark-hive"></span></li>
			<li class="li-skinitem" title="sunny"><span class="sunny" rel="sunny"></span></li>
		</ul>	
		</div>
	</div>
	<div region="west" border="true" split="true" title="导航栏" class="cs-west">
		<div class="easyui-accordion" fit="true" border="false">
				<div title="系统管理">
					<a href="javascript:void(0);" src="../page/userinfo.jsp" class="cs-navi-tab">用户管理</a></p>
					<a href="javascript:void(0);" src="../page/goods.jsp" class="cs-navi-tab">物品管理</a></p>
					<a href="javascript:void(0);" src="../page/clientinfo.jsp" class="cs-navi-tab">客户管理</a></p>
					<a href="javascript:void(0);" src="../page/units.jsp" class="cs-navi-tab">计量单位</a></p>
					<!-- <a href="javascript:void(0);" src="../page/guige.jsp" class="cs-navi-tab">规格型号</a></p> -->
					<a href="javascript:void(0);" src="../page/repertory.jsp" class="cs-navi-tab">仓库管理</a></p>
				</div>
				<div title="库房管理">
					<a href="javascript:void(0);" src="../page/putinstorage.jsp" class="cs-navi-tab">入库管理</a></p>
					<a href="javascript:void(0);" src="../page/OutboundOrder.jsp" class="cs-navi-tab">出库管理</a></p>
					<a href="javascript:void(0);" src="../page/stockTaking.jsp" class="cs-navi-tab">库存盘点</a></p>
					<a href="javascript:void(0);" src="../page/InventoryStatistics.jsp" class="cs-navi-tab">使用记录</a></p>
					<a href="javascript:void(0);" src="../page/stockSNTaking.jsp" class="cs-navi-tab">SN统计</a></p>
					<a href="javascript:void(0);" src="../page/EcharsCount.jsp" class="cs-navi-tab">库存趋势图</a></p>
				</div>
		</div>
	</div>
	<div id="mainPanle" region="center" border="true" border="false">
		 <div id="tabs" class="easyui-tabs"  fit="true" border="false" >
                <div title="首页">
				<div class="cs-home-remark">
					    	<p>登录名：${user.logname}</p>
					    	<p>角色：<c:if test="${user.power==1}">GUEST</c:if><c:if test="${user.power==10}">操作员</c:if><c:if test="${user.power==100}">超级管理员</c:if></p>
					    	<p>岗位：${user.username }</p>
					    	<p>电话：<c:if test="${user.tel==0 }"></c:if><c:if test="${user.tel!=0 }">${user.tel}</c:if> </p>
					    	
					    	<pre style="line-height: 30px;">
<strong>库存系统说明:</strong>
1、本系统采用java+web+mysql数据库的架构开发
2、数据库备份机制,会定期对系统数据库进行备份,防止数据丢失。
3、已经测试并兼容的浏览器包括谷歌浏览器、360浏览器(极速模式),IE浏览器,请使用兼容的浏览器访问,确保正常的使用。
4、为了确保数据的准确性,出库和入库操时,请确保草稿数据核对无误再进行提交,草稿数据一但提交,将无法对成功提交数据进行删除更改。
5、客户、物品、仓库信息,等关键信息需要提前录入,在入库或者出库操作时才会出现对应选项。
6、账户权限分为,管理员,操作员,guest,管理员拥有账号管理和关键信息录入更新和出库入库权限,操作员具有出库入库权限,guest只能查看和导出相关记录。
<strong>功能模块介绍:</strong>
1、系统管理模块:账号、客户、仓库、物品等信息进行录入和修改。
2、入库管理:物品入库,导出入库单,可以筛选和导出历史记录。
3、出库管理:物品出库,导出出库单,可以筛选和导出历史记录。
4、库存盘点:统计客户数量不为零的库存,可进行筛选和导出。
5、使用记录:统计所有出库入库的详细记录,可进行筛选和导出。
6、库存趋势图:查看客户某一具体物品的随着时间的库存变化(按月份分布)。
<strong>操作文档下载:</strong>
库存管理系统使简易用说明<a href="<%=basePath %>file/1.pdf" >download</a> 
</pre>	
				</div>
				</div>
        </div>
	</div>

	<div region="south" border="false" class="cs-south">@tianshaojie@gmail.com</div>
	
	<div id="mm" class="easyui-menu cs-tab-menu">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseother">关闭其他</div>
		<div id="mm-tabcloseall">关闭全部</div>
	</div>
	
	
	<div id="passwordid" class="easyui-dialog" title="修改密码" style="width:350px;height:210px;"   
	data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true,toolbar:[{
				text:'保存',
				iconCls:'icon-save',
				handler:function(){ savepassword(); }
			},{
				text:'关闭',
				iconCls:'icon-help',
				handler:function(){$('#passwordid').window('close')}
			}]">  
			<form id="updatepassward"  name="updatepassward">
	          <table border=0 style="width: 100%;line-height: 35px;">
              <tr>
                 <td align="right">旧密码：</td>
                 <td><!-- <input id="jmm" type="password" style="width:200px"> <span style="color: red;">*</span> -->
                         <input id="jmm"  class="easyui-textbox" data-options="type:'password',iconCls:'icon-man',required:true,validType:'minLength[6]'" style="width:200px"> 
                  </td>
              </tr>
              <tr>
                 <td align="right">新密码：</td>
                 <td>
                 
<!--                  <input id="xmm" type="password" style="width:200px"> <span style="color: red;">*</span> -->
                 <input id="xmm"  class="easyui-textbox" data-options="type:'password',iconCls:'icon-man',required:true,validType:'minLength[6]'" style="width:200px"> 
                  </td>
              </tr>
              <tr>
                 <td align="right">确认密码：</td>
                 <td><!-- <input id="qrmm" type="password" style="width:200px"> <span style="color: red;">*</span>  -->
                   <input id="qrmm"  class="easyui-textbox" data-options="type:'password',iconCls:'icon-man',required:true,validType:'minLength[6]'" style="width:200px">
                 </td>
              </tr>
           </table>  
           </form> 
	</div> 
	
	<div id="layout_north_zxMenu" style="width: 100px; display: none;" >
	<!--  <div data-options="iconCls:'icon-edit'" onclick="alert('a')">修改用户名</div>  -->
	 <div data-options="iconCls:'icon-edit'" onclick=" $('#passwordid').window('open') " >修改密码</div>  
	 <div data-options="iconCls:'icon-redo'" onclick="clears('<%=basePath%>')">退出</div>   
</div>
</body>
</html>